home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 6 / ads / s-tasoli < prev    next >
Text File  |  1996-02-12  |  8KB  |  154 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --            S Y S T E M . T A S K I N G _ S O F T _ L I N K S             --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.12 $                             --
  10. --                                                                          --
  11. --   Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc.  --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. --  This package contains a set of subprogram access variables that access
  37. --  some basic tasking primitives that are called from non-tasking code (e.g.
  38. --  the defer/undefer abort that surrounds a finalization action). To avoid
  39. --  dragging in the tasking all the time, we use a system of soft links where
  40. --  the links are initialized to dummy non-tasking versions, and then if the
  41. --  tasking is initialized, they are reset to the real tasking versions.
  42.  
  43. package System.Tasking_Soft_Links is
  44.  
  45.    pragma Elaborate_Body;
  46.  
  47.    --  First we have the access subprogram types used to establish the links.
  48.    --  The approach is to establish variables containing access subprogram
  49.    --  values which by default point to dummy no tasking versions of routines.
  50.  
  51.    type No_Param_Proc    is access procedure;
  52.    type Addr_Param_Proc  is access procedure (Addr : Address);
  53.  
  54.    type Get_Address_Call is access function return Address;
  55.    type Set_Address_Call is access procedure (Addr : Address);
  56.  
  57.    type Get_Natural_Call is access function return Natural;
  58.    type Set_Natural_Call is access procedure (Len : Natural);
  59.  
  60.    --  Declarations for the no tasking versions of the required routines
  61.  
  62.    procedure Abort_Defer_NT;
  63.    --  Defer task abortion (non-tasking case, does nothing)
  64.  
  65.    procedure Abort_Undefer_NT;
  66.    --  Undefer task abortion (non-tasking case, does nothing)
  67.  
  68.    procedure Task_Lock_NT;
  69.    --  Lock out other tasks (non-tasking case, does nothing)
  70.  
  71.    procedure Task_Unlock_NT;
  72.    --  Release lock set by Task_Lock (non-tasking case, does nothing)
  73.  
  74.    Abort_Defer : No_Param_Proc := Abort_Defer_NT'Access;
  75.    --  Defer task abortion (task/non-task case as appropriate)
  76.  
  77.    Abort_Undefer : No_Param_Proc := Abort_Undefer_NT'Access;
  78.    --  Undefer task abortion (task/non-task case as appropriate)
  79.  
  80.    Lock_Task : No_Param_Proc := Task_Lock_NT'Access;
  81.    --  Locks out other tasks. Preceding a section of code by Task_Lock and
  82.    --  following it by Task_Unlock creates a critical region. This is used
  83.    --  for ensuring that a region of non-tasking code (such as code used to
  84.    --  allocate memory) is tasking safe. Note that it is valid for calls to
  85.    --  Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
  86.    --  only the corresponding outer level Task_Unlock will actually unlock.
  87.  
  88.    Unlock_Task : No_Param_Proc := Task_Unlock_NT'Access;
  89.    --  Releases lock previously set by call to Lock_Task. In the nested case,
  90.    --  all nested locks must be released before other tasks competing for the
  91.    --  tasking lock are released.
  92.  
  93.    function  Get_Jmpbuf_Address_NT return  Address;
  94.    procedure Set_Jmpbuf_Address_NT (Addr : Address);
  95.  
  96.    Get_Jmpbuf_Address : Get_Address_Call := Get_Jmpbuf_Address_NT'Access;
  97.    Set_Jmpbuf_Address : Set_Address_Call := Set_Jmpbuf_Address_NT'Access;
  98.  
  99.    function  Get_GNAT_Exception_NT return  Address;
  100.    procedure Set_GNAT_Exception_NT (Addr : Address);
  101.  
  102.    Get_Gnat_Exception : Get_Address_Call := Get_GNAT_Exception_NT'Access;
  103.    Set_Gnat_Exception : Set_Address_Call := Set_GNAT_Exception_NT'Access;
  104.  
  105.    function  Get_Sec_Stack_Addr_NT return  Address;
  106.    procedure Set_Sec_Stack_Addr_NT (Addr : Address);
  107.  
  108.    Get_Sec_Stack_Addr : Get_Address_Call := Get_Sec_Stack_Addr_NT'Access;
  109.    Set_Sec_Stack_Addr : Set_Address_Call := Set_Sec_Stack_Addr_NT'Access;
  110.  
  111.    function  Get_Exc_Stack_Addr_NT return Address;
  112.    procedure Set_Exc_Stack_Addr_NT (Addr : Address);
  113.  
  114.    Get_Exc_Stack_Addr : Get_Address_Call := Get_Exc_Stack_Addr_NT'Access;
  115.    Set_Exc_Stack_Addr : Set_Address_Call := Set_Exc_Stack_Addr_NT'Access;
  116.  
  117.  
  118.    function  Get_Message_Length_NT return Natural;
  119.    procedure Set_Message_Length_NT (Len : Natural);
  120.  
  121.    Get_Message_Length : Get_Natural_Call := Get_Message_Length_NT'Access;
  122.    Set_Message_Length : Set_Natural_Call := Set_Message_Length_NT'Access;
  123.  
  124.    function  Get_Message_Addr_NT return Address;
  125.    procedure Set_Message_Addr_NT (Addr : Address);
  126.  
  127.    Get_Message_Addr : Get_Address_Call := Get_Message_Addr_NT'Access;
  128.    Set_Message_Addr : Set_Address_Call := Set_Message_Addr_NT'Access;
  129.  
  130.    --------------------------------
  131.    -- Secondary Stack Soft-Links --
  132.    --------------------------------
  133.  
  134.    --  The inclusion of these soft-links in the Tasking_Soft_Links package is
  135.    --  somewhat of a misnomer. The SS_Init/SS_Free mechanism is independent
  136.    --  of the use of tasking. If no unit uses the secondary stack, the SS_Init
  137.    --  and SS_Free links will default to a dummy implementation.  Otherwise,
  138.    --  the elaboration of System.Secondary_Stack will establish links to the
  139.    --  appropriate routines.
  140.  
  141.    procedure SS_Init_NT (Stk : out Address; Size : Natural);
  142.    --  Initialization of the secondary stack (if no sec-stack does nothing)
  143.  
  144.    procedure SS_Free_NT (Stk : Address);
  145.    --  Release the secondary stack (if no sec-stack does nothing)
  146.  
  147.    type Proc_SS1 is access procedure (X : Address);
  148.    type Proc_SS2 is access procedure (X : out Address; Y : Integer);
  149.  
  150.    SS_Init : Proc_SS2 := SS_Init_NT'Access;
  151.    SS_Free : Proc_SS1 := SS_Free_NT'Access;
  152.  
  153. end System.Tasking_Soft_Links;
  154.